home *** CD-ROM | disk | FTP | other *** search
- Path: swidir.switch.ch!epflnews!news
- From: Niels Hilbrink <niels@imacsg2.epfl.ch>
- Newsgroups: comp.lang.c++
- Subject: Q: how to create an Object without creating the whole object
- Date: Tue, 12 Mar 1996 11:15:37 +0100
- Organization: EPFL
- Message-ID: <31454EC9.167E@imacsg2.epfl.ch>
- NNTP-Posting-Host: imacsg2.epfl.ch
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (X11; I; IRIX 5.3 IP22)
-
- Hi,
-
- Oke the problem is this (maybe it's in a FAQ but couldn't find the faq
- so ...):
-
- Say you've got a class A which is composed of say 10 other class
- (inheritance multiple and single whatever). But if I create an object
- with new this class 'explodes' (all the member functions are created of
- all the parentclasses) so you want the initialize only those parent
- class you need say only class B.
-
- How do you do that ?
-
- something like:
-
- Aobj = (A*) new A::B()
-
- But this doen't work, can anybody tell me what will ?
-
- oh yeah this works of course :
- Bobj = new B;
-
- Aobj = (A*) Bobj;
-
- but I don't want that, I don't want first to have to create a B object
- and "attach" it to the A object
-
- Gr.
- Niels
-
- --
-
- The most overlooked advantage to owning a computer is
- that if they foul up there's no law against wacking
- them around a little.
-
- ------------------------------------------------------------
- Koen D'Hondt Niels Hilbrink
- koen@dutlhs1.lr.tudelft.nl niels@dutlcc3.lr.tudelft.nl
-
- **** Ripley Software Development ****
- (finger niels@dutlcc3.lr.tudelft.nl for more information.)
- ------------------------------------------------------------
-